package com.tangyee.utils;

import android.content.BroadcastReceiver;
import android.content.IntentFilter;

/**
 * @author leeguiyang@yeah.net
 * @describe 这是获取网络会话是的数据，只要实现这个借口就能使用
 * 发送三个参数是注册，发送两个参数是登录，如果成功，state = 4，sessionid= String
 */
public interface SessionHelper {
    /**
     * 登录模块的数据,
     */
    //登录和获取sessionid的url
    public final String LOGINURL = "https://www.tangyee.com/Mobile/Login";
    //注册的url
    public final String REGISTERURL = "https://www.tangyee.com/Mobile/Login/Reg";
    //返回json数据时 ｛"state":Integer,"sessionid":String｝
    public final String STATE = "state";
    public final String SESSIONID = "sessionid";

    //登录时url需要的参数
    public final String USERLOGINKEY = "user";
    public final String PWDLOGINKEY = "pwd";
    //登录后返回的状态
    public final int LOGINSUCCESSFUL = 4;//登录成功
    public final int LOGINNOEXISTUSER = 0;//用户不存在
    public final int LOGININFOMISMATCH = 1;//登录信息不匹配
    //注册时需要的参数
    public final String USERREGISTERKEY = "username";
    public final String PWDREGISTERKEY = "pwd";
    public final String PHONEREGISTERKEY = "phone";
    //注册时候返回的状态结果
    public final int REGISTERED = 1;//已经注册
    public final int REGISTERSUCCESS = 4;//注册成功

    /**
     * 自定义的服务和广播的 action name
     */
    //用于服务
    public final String I_NEED_SESSIONID_BY_SERVICE = "com.tangyee.I_NEED_SESSIONID_SERVICE";
    public final String I_WANT_REGISTER_BY_SERVICE = "com.tangyee.I_WANT_REGISTER_SERVICE";
    //用于广播
    public final String I_NEED_SESSIONID_BY_BROAD = "com.tangyee.I_NEED_SERVICE_BROAD";
    public final String I_WANT_REGISTER_BY_BROAD = "com.tangyee.I_WANT_REGISTER_BROAD";

    public final String GET_A_SESSIONID = "com.tangyee.GAVE_A_SESSIONID";//接受广播
    //用于本地Intent数据传送的key,上面的sessionid
    public final String JSON = "json";
    public final String USERNAME = "username";
    public final String PASSWORD = "password";
    public final String PHONENUMBER = "phonenumber";
    //就是用于提醒大家调用时不要忘了,可以自定义一个接收器，获取的权限只有 com.tangyee.GAVE_A_SESSIONID
    /**
     * 获取sessionid时先要注册一个接收器
     * 最好在onCreate()中注册，采用动态注册的方法，
     */
    public void registerSessionReceiver();/**{
        如果只接受Sessionid一般写法如下，你也可以进行其他处理
        sessionReceiver = new BroadcastReceiver() {
         @Override
        public void onReceive(Context context, Intent intent) {
            localHandler(context,intent);//本地处理的方法
        }
        };
        IntentFilter filter = new IntentFilter(GET_A_SESSIONID);
        registerReceiver(sessionReceiver,filter);
     }
     */
    /**
     * 注销接收器，一般在onDestory
     */
    public void unregisterSessionReceiver();//注销接收器
}
